<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateArchivesTable extends Migration {
  /**
   * Run the migrations.
   *
   * @return void
   */
  public function up() {
    Schema::create( 'archives', function ( Blueprint $table ) {
      $table->increments( 'id' );
      $table->string( 'title', 200 );
      $table->text( 'content', 200 );
      $table->integer('user_id')->unsigned();
      $table->integer( 'category_id' )->unsigned();
      $table->foreign("category_id")
            ->references('id')->on('categories');
      $table->foreign("user_id")
            ->references('id')->on('users');
      $table->timestamps();
    } );
  }

  /**
   * Reverse the migrations.
   *
   * @return void
   */
  public function down() {
    Schema::dropIfExists( 'archives' );
  }
}
